package com.sc.nft.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dto.ReleaseFrozenPointsDTO;
import com.sc.nft.entity.UserEcologyPointsQuotaRecords;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.entity.vo.ecology.AdminExpiredRecordsVO;
import com.sc.nft.entity.vo.ecology.MyPointsRecordsVO;
import com.sc.nft.enums.EcologyIncomeTypeEnum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 用户生态燃料额度记录表(user_ecology_points_quota_records)数据Mapper
 *
 * @author Sun
 * @since 2023-11-23 11:22:44
 * @description 由 Mybatisplus Code Generator 创建
*/
@Mapper
public interface UserEcologyPointsQuotaRecordsMapper extends BaseMapper<UserEcologyPointsQuotaRecords> {

    /**
     * 获取过期记录
     * @param page
     * @param userId
     * @param incomeType
     * @param startTime
     * @param endTime
     * @return
     */
    Page<AdminExpiredRecordsVO> expiredRecords(Page page, @Param("userId") Long userId,@Param("incomeType") Integer incomeType, @Param("startTime") Date startTime, @Param("endTime")Date endTime);

    /**
     * 获取待释放记录
     * @param page
     * @param userId
     * @return
     */
    Page<MyPointsRecordsVO> stayReleaseRecords(Page page, @Param("userId") Long userId);

    /**
     * 失效记录
     * @param page
     * @param userId
     * @return
     */
    Page<MyPointsRecordsVO> myExpiredRecords(Page page,@Param("userId") Long userId);

    /**
     * 获取待结算的记录
     * @param userId
     * @return
     */
    UserEcologyPointsQuotaRecords stayReleaseRecordsByUserIdAndOne(@Param("userId") Long userId);

    /**
     * 减去冻结金额 加入到已释放金额
     * @param id
     * @param freezeAmount
     * @return
     */
    Boolean subFreezeAmountAndSubReleaseAmountById(@Param("id") Long id,@Param("freezeAmount") BigDecimal freezeAmount);

    /**
     * 获取平台冻结的生态积分总量(有效期内)
     * @return
     */
    BigDecimal getSumFrozenEcologyPoints();

    List<ReleaseFrozenPointsDTO> releaseFrozenPoints();

    Boolean removeAll();

}
